home *** CD-ROM | disk | FTP | other *** search
- {$A+,D-,E-,F+,I-,N-,O-,R-,S-,V-}
- UNIT TT_32Bit;
-
- (*
- REVISION : 0.1ß
- LAST UPDATE : 31 May, 1989
- PROGRAMMER : Thomas A. Toth Jr.
- CompuServ ID: [71071,372]
-
- Copyright(c) 1989, All rights reserved. Synergy Software Developers.
- Any Object and Borland International '.TPU' files (for this version)
- are released to the Public Domain for the betterment of mankind. These
- files may be distributed (free of charge, though!!) to others, but all
- files MUST be left unmodified (if you happen to find a fixable bug, fix
- it, make note of it at the top of this file, upload a new copy onto the
- BPROGA forum on CompuServ (Turbo 5 DL), and try to contact me!!!).
- If any of these routines are used in any distributable applications, I
- expect that you will give me credit on your programs' "log-on" screen
- or in the opening pages of your documentation! .ASM Source-code for
- Move32.obj will be made available at a later date.
-
- * All code uploaded by myself in the future can be found by entering
- 'TT_Lib' at the 'keyword' prompt when entering the 'Browse' option
- in the BPROGA forum (turbo 5 DL) on CompurServ!!
-
- DESCRIPTION:
- A small Unit to give the programmer auto-detecting routines to utilize the
- 32-bit data bus of the 80386/80486 micro-processors, when pressent. If one
- of these processors is NOT in use, these routines use 16 XFers, stil making
- them a good deal faster than the Turbo Move() proc when moving large blocks
- of information. All procedures were coded in assembler for optimal speed
- and was developed using Borland's Turbo Assembler, version 1.0.
-
- Right now, there is only 2 procedures and one global 'variable' decalred
- public. As time marches on, and as I can drift aside from the financially
- profitable programming endeavors, it will contonue to grow with more
- features.
-
- This unit the first of a large series of libraries and utilities for the
- programming community at large. Most of the TP Unit filenames will be
- prefaced with 'TT_' (so you can remember me!). A good deal of the routines
- are modified copies of some code that serves as the kernal for an operating
- enviroment known as 'TOE' (developed by myself) which is used by all
- applications being developed by our company. 'TOE' is basically an MS-DOS
- version of an OS/2 DLL. A large portion of it is a kind of a text-based
- Presentation Manager. Once the PC world comewhat settles on a standard
- multi-tasking (and hopefully mutli-user) operating system, I plan to mass-
- market 'TOE'. So keep an eye open a couple years from now. A number of
- programmers accross the country are now using TOE to develope some of their
- applications, and LOVE it. You may be making 'calls' to TOE one day too!
-
-
- AKNOWLEDGMENTS:
- The routine called in the initialization section uses a concept borrowed
- from Mark Boler's CpuInfo function found in CPUTP.ARC in the Borland
- Program Library A (Turbo 5.0 Source code). Thanks to folks like Mr. Boler,
- Kim Kokkonnen and many others, I have learned more about the joys, tricks
- and traps associated with systems-level programming through studying and
- devouring their source-code that has been uploaded there.
-
-
- NOTES:
- - MAKE SURE that TT_32Bit is 'Used' before any other unit that may call
- either of the Move32?() procs in their 'Initialization' routine(s)!!!!
- You won't send your machine to lunch , or anything silly like that, but
- you will instead only get 16-bit throughput because TT_32Bit has not yet
- been initialized!
-
- - Both of these routines are most effective on Xfer's of more than 1-2K,
- this especially applies to Move32o() because of the normalizing of pointers
- and 'range checking'. The exception would be in cases where you have xfers
- that may overlap themselves when using Turbo's Move(), you can use Move32o()
- in its place to avoid that tragic event from occuring!
-
- - Please note the compiler directive {$O-} above; it is vitally important to
- remember that this unit should NOT be overlayed due to the fact that it has
- an initialization section (nothing fatal in its' own right, but...) and the
- fact that this is a routine designed for optimal performance, Overlays are
- not!
-
- If you have any ideas, criticisms, etc., my CompuServ ID is at the top of
- this file. Would love to hear from somebody, shit...anybody! Keep your eyes
- open for more code from us in the near future!
-
- [=Thom=]
- Synergy Software
- 'Dedicated to a Bug-free America!'
- ________________________________________________________________________________
-
- The routines provided (with some notes) are:
-
- PROCEDURE Check32Bit; { **** Not decalred 'PUBLIC' **** }
- - Sets the boolean variable named 'Has386' to TRUE if a
- 32-bit micro-processor is present in the system. It is
- automatically called in the 'INIT' section of the TT_Moves
- unit. 'Has386' is declared 'public' by being declared in
- INTERFACE section so that you can access it also.
-
- PROCEDURE Move32(VAR Source, Dest; BytesToMove : WORD);
- - This is the 'low-level' or kernal routine for the 32-bit
- replacement for Move(). If a 32 bit processor is in use,
- Move32() will process that Xfer utilizing REP MOVSD (32 bits).
- Otherwise, REP MOVSW is used (16-bits).
- - Move32() automatically adjusts the 'BytesToMove' argument for
- 'DWORD' (or 'WORD') alignment internally.
- - No checks for memory overwrite or Segment over-run are made
- by this routine. It is your responsibility to insure that the
- Offset addresses for both 'Source' & 'Dest' plus 'BytesToMove'
- is less than $FFFF, as well as insuring that 'Dest' is at a
- memory location below or at Source+BytesToMove. These same
- rules are being followed if you use the Turbo Move() proc.
-
- PROCEDURE Move32o(VAR Source, Dest; BytesToMove : WORD);
- - This is basically a higher level 'pre-processor' to Move32().
- The only difference is that 'Move32o()' first normalizes both
- pointers to insure that you won't have any 'segment over-run';
- so if the pointer pushed on the stack that was assigned by
- Turbo for 'Source' is $2A70:$F10A, it will be 'normalized' to
- $3980:$000A, allowing us move up $FFF5 bytes (in this case),
- and not 'wrap' around back to $3980:$0000.
- - Along with both pointers being normalized, a check is done to
- insure that the first byte moved from 'Source' to 'Dest' does
- not lie some between 'Source' and 'Source'+'BytesToMove'. If
- this is the case, then Move32o() will move this data starting
- at the end of each array.
- An example would be:
- Move32o(Mem[$b800:0000],Mem[$b800:00A0],3840);
- As you can see, the first 160 bytes would be replicated
- throughout that memory array for the next 3680 bytes,
- IF we were to use either Move() or my Move32() procedures.
- Move32o() looks for this sort of overlap, and will move it
- without error by starting at the end of both 'Source' & 'Dest'.
-
- *)
-
- { ░░▒▒▓▓██ The} INTERFACE {Section ██▓▓▒▒░░ }
-
- CONST
- Has386 : BOOLEAN = FALSE;
-
-
- PROCEDURE Move32(VAR Source, Dest; BytesToMove : WORD);
-
- PROCEDURE Move32o(VAR Source, Dest; BytesToMove : WORD);
-
-
- { ░░▒▒▓▓██ The} IMPLEMENTATION {Section ██▓▓▒▒░░ }
-
- {$L Move32.obj}
-
- procedure Check32Bit; external;
- Procedure Move32; external;
- Procedure Move32o; external;
-
-
- { ░░▒▒▓▓██ The Initialization Section ██▓▓▒▒░░ }
- BEGIN
- Check32Bit; { Initializes Typed Const named 'Has386' for later use.}
- END. { INIT }